package com.scarecrow.compack.component.view {
	
	import com.scarecrow.olga.game.component.GameComponent;
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	
	/**
	 * This basic component shows an animated movieclip and contains
	 * methods to call for specific animations.
	 * 
	 * ...
	 * @author Santiago.J.Elizalde
	 */
	public class AnimatedDisplay extends BaseDisplay {
		
		private var anim:MovieClip;
		
		private var _displayClass:Class;
		
		public function AnimatedDisplay() {
			
		}
		
		override public function set displayClass(value:Class):void {
			_displayClass = value;
			display = new _displayClass() as DisplayObject;
			anim = display as MovieClip;
		}
		
		public function animate(label:String):void {
			
			if (!label || !anim) return;
			if (anim.currentLabels.indexOf(label) != -1) {
				anim.gotoAndPlay(label);
			}
		}
		
		public function stopAtLabel(label:String):void {
			
			if (!label || !anim) return;
			anim.gotoAndStop(label);
		}
		
		public function stop():void {
			
			if (!anim) return;
			anim.stop();
		}
		
		public function reset():void {
			
			if (!anim) return;
			anim.gotoAndStop(1);
		}
		
		override public function update(ms:uint = 0):void {
			super.update(ms);
		}
	}
}